package com.xnyzc.lhy.mis.controller.cmsapi.engine;

import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.mis.entity.cms.driver.DriverUserInfo;
import com.xnyzc.lhy.mis.entity.param.cms.dict.DictParam;
import com.xnyzc.lhy.mis.entity.param.cms.engine.EngineParam;
import com.xnyzc.lhy.mis.entity.result.cms.engine.RulesSnapshot;
import com.xnyzc.lhy.mis.service.cms.driver.DriverManageService;
import com.xnyzc.lhy.mis.service.engine.CmsEngineManageService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 风控引擎相关
 * @author wangshuo
 * @date 2019-12-16 10:42
 */
@RestController
@RequestMapping("/cmsapi/engine")
public class CmsEngineManageController {


    @Autowired
    private CmsEngineManageService engineManageService;

    /**
     * 查询风控留证记录列表
     * @return
     */
    @ApiOperation(value = "查询风控留证记录列表", notes = "查询风控留证记录列表")
    @PostMapping(value = "/getEngineManagementList")
    public Rv getEngineManagementList(
            @ApiParam(name = "param", value = "接入传参") @RequestBody EngineParam param
    ) {
        return engineManageService.getEngineManagementList(param);
    }

    /**
     * 查询字典规则类型
     * @return
     */
    @ApiOperation(value = "查询字典规则类型", notes = "查询字典规则类型")
    @GetMapping(value = "/getDictEngineRuleList")
    public Rv getDictEngineRuleList(
    ) {
        return engineManageService.getDictEngineRuleList();
    }

    /**
     * 查看规则快照
     * @return
     */
    @ApiOperation(value = "查看规则快照", notes = "查看规则快照")
    @GetMapping(value = "/getRulesSnapshot")
    public Rv getRulesSnapshot(Long recordId
    ) {
        return engineManageService.getRulesSnapshot(recordId);
    }

    /**
     * 查看特征快照
     * @return
     */
    @ApiOperation(value = "查看特征快照", notes = "查看特征快照")
    @GetMapping(value = "/getCharacteristicSnapshot")
    public Rv getCharacteristicSnapshot(Long recordId
    ) {
        return engineManageService.getCharacteristicSnapshot(recordId);
    }

    /**
     * 风控字典规则业务场景
     * @return
     */
    @ApiOperation(value = "风控字典规则业务场景", notes = "风控字典规则业务场景")
    @GetMapping(value = "/getRiskControlNode")
    public Rv getRiskControlNode(
    ) {
        return engineManageService.getRiskControlNode();
    }

    /**
     * 风控规则配置列表
     * @return
     */
    @ApiOperation(value = "风控规则配置列表", notes = "风控规则配置列表")
    @GetMapping(value = "/getRiskControlRulesList")
    public Rv getRiskControlRulesList(Integer node
    ) {
        return engineManageService.getRiskControlRulesList(node);
    }

    /**
     * 风控规则配置详情
     * @return
     */
    @ApiOperation(value = "风控规则配置详情", notes = "风控规则配置详情")
    @GetMapping(value = "/getRiskControlRulesDetails")
    public Rv getRiskControlRulesDetails(Long rulesId
    ) {
        return engineManageService.getRiskControlRulesDetails(rulesId);
    }

    /**
     * 风控规则配置修改
     * @return
     */
    @ApiOperation(value = "风控规则配置修改", notes = "风控规则配置修改")
    @PostMapping(value = "/getUpdateRiskControlRules")
    public Rv getUpdateRiskControlRules(
            @ApiParam(name = "param", value = "接入传参") @RequestBody RulesSnapshot param
    ) {
        return engineManageService.getUpdateRiskControlRules(param);
    }


}
